import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex); //vue的插件机制

//Vuex.Store 构造器选项
const store = new Vuex.Store({
  state: {
    currentMusicDet: "", //当前播放的音乐详情
    currentMusicUrl: "", //当前播放的音乐地址
    currentMusicSimilar: "", //当前播放的相似歌曲
    currentMusicComment: "", //当前播放的精彩评论
    isPlay: true, //判断是否在播放
    palyList: [], //播放列表
    currentIndex: 0, //当前播放音乐的索引
  },
  mutations: {
    //当前播放的音乐详情
    changeCurrentMusicDet(state, item) {
      state.currentMusicDet = item;
    },
    //当前播放的音乐地址
    changeCurrentMusicUrl(state, url) {
      state.currentMusicUrl = url;
    },
    //当前播放的相似歌曲
    changeCurrentMusicSimilar(state, item) {
      state.currentMusicSimilar = item;
    },
    //当前播放的精彩评论
    changeCurrentMusicCommentr(state, item) {
      state.currentMusicComment = item;
    },
    //监听是否在播放
    changePlay(state, flag) {
      state.isPlay = flag;
    },
    // 获取播放列表
    changePalyList(state, arr) {
      state.palyList = arr;
    },
    //监听播放歌曲索引
    changeCurrentIndex(state, index) {
      state.currentIndex = index;
    },
  },
});
export default store;
